﻿
#SingleInstance, Force
#NoEnv
#notrayicon
SetBatchLines, -1
thestart:
FileSelectFile, file, 3, , Pick your iOS screenshot, Screenshots (*.png; *.jpg; *.jpeg; *.gif)
if not file
	exitapp
; Uncomment if Gdip.ahk is not in your standard library
;#Include, Gdip.ahk
gui, margin, 5
gui, font, s14 q5, Arial

File1 = %file%
newfile:=createscreenshot(file1, "android2.png", "temp.png")
gui, add, picture, , %newfile%
gui, add, radio, vcolor section gswitch checked, Black
gui, add, radio, gswitch ys, While
gui, add, button, x5 gsave section, Save
gui, add, button, section ys gnew, New
gui, add, button,  ys gcancel, Done
gui, show,, Android Screenshot Maker
return
switch:
gui,submit, nohide



if color=1
{
newfile:=createscreenshot(file1, "android2.png", "temp.png")
}
else
{
newfile:=createscreenshot(file1, "android.png", "temp.png")
}
guicontrol, ,Static1,%newfile%
return

save:
FileSelectFile, outfile, s, , Save your new screenshot, Screenshots (*.png)
if not outfile
	return
if not instr(outfile, ".png")
{
	outfile=%outfile%.png
}
FileMove, temp.png, %outfile% , 1
return

guiclose:

exitapp
new:
gui, destroy
gosub thestart

return
cancel:
exitapp



; If the images we want to work with do not exist on disk, then download them...

createscreenshot(file1, file2, output)
{

If !pToken := Gdip_Startup()
{
	MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system
	ExitApp
}
; Create a 500x500 pixel gdi+ bitmap (this will be the entire drawing area we have to play with)
pBitmap := Gdip_CreateBitmap(320, 480)

; Get a pointer to the graphics of the bitmap, for use with drawing functions
G := Gdip_GraphicsFromImage(pBitmap)


; Get bitmaps for both the files we are going to be working with
pBitmapFile1 := Gdip_CreateBitmapFromFile(File1), pBitmapFile2 := Gdip_CreateBitmapFromFile(File2)

; Get the width and height of the 1st bitmap
Width := Gdip_GetImageWidth(pBitmapFile1), Height := Gdip_GetImageHeight(pBitmapFile1)

Gdip_DrawImage(G, pBitmapFile1, 0, 5, 320, 480, 0, 0, Width, Height)


Width := Gdip_GetImageWidth(pBitmapFile2), Height := Gdip_GetImageHeight(pBitmapFile2)
Gdip_DrawImage(G, pBitmapFile2, 0, 0, 320, 25, 0, 0, 320, 25)

; Dispose of both of these bitmaps we created from the images on disk, as they are now been used...They are on
; the graphics of the bitmap of our created "canvas"
Gdip_DisposeImage(pBitmapFile1), Gdip_DisposeImage(pBitmapFile2)



if not instr(output,".png")
{
	output=%output%.png
}

Gdip_SaveBitmapToFile(pBitmap, output)

; The bitmap can be deleted
Gdip_DisposeImage(pBitmap)

; The graphics may now be deleted
Gdip_DeleteGraphics(G)

return output
}

Gdip_Shutdown(pToken)
ExitApp
Return